<!DOCTYPE html>
<html>
<head>
{include file="public/meta"} 
<title>找回密码 - {$maccms.site_name} </title>
<meta name="keywords" content="{$maccms.site_keywords}"/>
<meta name="description" content="{$maccms.site_description}"/>
{include file="public/include"}
</head>
<body>
{include file="public/head"}
<div id="conch-content" class="conch-content">
<div class="conch-ctwrap">
    <div class="container">
    <div class="hl-member">
    <div class="hl-reg-wrap">
       	<form method="post" id="fm" action="">
			<input type="hidden" name="ac" value="{$param['ac']}">
			<h2 class="hl-reg-title">{$param['ac_text']}找回密码</h2>
			<div class="hl-reg-group">
				<label>{$param['ac_text']}</label><input type="text" id="to" name="to" class="hl-reg-control hl-reg-w2" placeholder="请输入您绑定的{$param['ac_text']}"><input type="button" class="hl-reg-w3 hl-reg-yzm hl-text-conch" id="btn_send" value="发送验证码"/>
			</div>
		</form>
		<form method="post" id="fm2" action="">
			<input type="hidden" name="ac" value="email">
			<div class="hl-reg-group">
				<label>验证码</label><input type="text" id="code" name="code" class="hl-reg-control" placeholder="请输入{$param['ac_text']}收到的验证码">
			</div>
			<div class="hl-reg-group">
				<label>新密码</label><input type="password" class="hl-reg-control" id="user_pwd" name="user_pwd" placeholder="请输入新密码">
			</div>
			<div class="hl-reg-group">
				<label>确认密码</label><input type="password" class="hl-reg-control" id="user_pwd2" name="user_pwd2" placeholder="请输入确认密码">
			</div>
			<input type="button" id="btn_submit" class="hl-btn-submit hl-bg-conch" value="重置密码">
		</form>
        <div class="hl-reg-go hl-text-center clearfix">
            <a href="{:url('user/login')}">登录账号</a><a href="{:url('user/findpass')}">用密保找回</a>{if$_GET['ac']=='phone'}<a href="{:url('user/findpass_msg')}?ac=email">用邮箱找回</a>{elseif$_GET['ac']=='email'}<a href="{:url('user/findpass_msg')}?ac=phone">用手机找回</a>{/if}
        </div>
    </div>
    </div>
    </div>
</div>
</div>
{include file="public/foot"}
<script type="text/javascript">
	$(function(){
		$("body").bind('keyup',function(event) {
			if(event.keyCode==13){ $('#btnLogin').click(); }
		});
		$('#btn_send').click(function() {
			if ($('#to').val()  == '') { alert('请输入{$param["ac_text"]}！'); $("#to").focus(); return false; }
			$.ajax({
				url: "{:url('user/findpass_msg')}",
				type: "post",
				dataType: "json",
				data: $('#fm').serialize(),
				beforeSend: function () {
					$("#btn_send").val("loading...");
				},
				success: function (r) {
					alert(r.msg);
				},
				complete: function () {
					$('#verify').click();
					$("#btn_send").val("发送邮件");
				}
			});
		});

		$('#btn_submit').click(function() {
			if ($('#to').val()  == '') { alert('请输入{$param["ac_text"]}'); $("#to").focus(); return false; }
			if ($('#code').val()  == '') { alert('请输入验证码！'); $("#code").focus(); return false; }
			if ($('#user_pwd').val()  == '') { alert('请输入新密码！'); $("#user_pwd").focus(); return false; }
			if ($('#user_pwd2').val()  == '') { alert('请输入确认密码！'); $("#user_pwd2").focus(); return false; }
			if ($('#user_pwd').val()  != $('#user_pwd2').val() ) { alert('二次密码不一致！'); $("#user_pwd2").focus(); return false; }

			var data= {ac:'{$param["ac"]}',to:$('#to').val(),code:$('#code').val(),user_pwd:$('#user_pwd').val(),user_pwd2:$('#user_pwd2').val()};
			$.ajax({
				url: "{:url('user/findpass_reset')}",
				type: "post",
				dataType: "json",
				data: data,
				beforeSend: function () {
					$("#btn_submit").css("background","#fd6a6a").val("loading...");
				},
				success: function (r) {
					alert(r.msg);
				},
				complete: function () {
					$("#btn_submit").css("background","#fa4646").val("重置密码");
				}
			});
		});
	});
</script>
</body>
</html>